import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProvideServiceVO, ProvideServiceForm, ProvideServiceQuery } from '@/api/sheet/provideService/types';

/**
 * 查询应用控件列表
 * @param query
 * @returns {*}
 */

export const listProvideService = (query?: ProvideServiceQuery): AxiosPromise<ProvideServiceVO[]> => {
  return request({
    url: '/system/provideService/list',
    method: 'get',
    params: query
  });
};

export const listAllProvideService = (query?: ProvideServiceQuery): AxiosPromise<ProvideServiceVO[]> => {
  return request({
    url: '/system/provideService/listAll',
    method: 'get',
    params: query
  });
};

/**
 * 查询应用控件详细
 * @param serviceId
 */
export const getProvideService = (serviceId: string | number): AxiosPromise<ProvideServiceVO> => {
  return request({
    url: '/system/provideService/' + serviceId,
    method: 'get'
  });
};

/**
 * 新增应用控件
 * @param data
 */
export const addProvideService = (data: ProvideServiceForm) => {
  return request({
    url: '/system/provideService',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用控件
 * @param data
 */
export const updateProvideService = (data: ProvideServiceForm) => {
  return request({
    url: '/system/provideService',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用控件
 * @param serviceId
 */
export const delProvideService = (serviceId: string | number | Array<string | number>) => {
  return request({
    url: '/system/provideService/' + serviceId,
    method: 'delete'
  });
};
